package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.ResultCode;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.BookingScheduleRuleVo;
import org.apache.commons.collections4.Get;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleRuleController  {

    @Autowired
    ScheduleService scheduleService;

    /**
     * 获取对应科室排版计划
     * @param page
     * @param limit
     * @param hoscode
     * @param depcode
     * @return
     */
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public ResultCode.R getScheduleRule(@PathVariable String page, @PathVariable String limit, @PathVariable String hoscode, @PathVariable String depcode){

        Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hoscode,depcode);

        return ResultCode.R.ok().data(map);
    }

    /**
     * 获取排班信息
     * @param hoscode
     * @param depcode
     * @param workDate
     * @return
     */
    //${api_path}/getScheduleDetail/${hoscode}/${depcode}/${workDate}
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public ResultCode.R getScheduleDetail(@PathVariable String hoscode, @PathVariable String depcode, @PathVariable String workDate){

        Date workday = new DateTime(workDate).toDate();
        List<Schedule> scheduleList = scheduleService.getScheduleDetail(hoscode,depcode,workday);
        return ResultCode.R.ok().data("list",scheduleList);
    }
}
